Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add "is-genesis" check #267

Merged
merged 14 commits into from
Jun 20, 2022
Merged

feat!: add "is-genesis" check #267

merged 14 commits into from
Jun 20, 2022

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Jun 19, 2022

Closes: #XXX

What is the purpose of the change

This pull request exports an "is-genesis" boolean which is set to "true" during init-chain. We can then use this value to properly sign gentxs that happen at a non zero height.

Brief Changelog

  • Adds isGenesis to Context struct as well as IsGenesis function
  • Adds isGenesis check to antehandler for gentxs
  • Sets isGenesis to true during init chain and resets to false after completion

Testing and Verifying

This change is already covered by existing tests

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

czarcas7ic and others added 2 commits June 20, 2022 09:26
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@czarcas7ic czarcas7ic marked this pull request as ready for review June 20, 2022 14:52
@czarcas7ic czarcas7ic self-assigned this Jun 20, 2022
@@ -269,7 +269,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
}

// retrieve signer data
genesis := ctx.BlockHeight() == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this || here, and just use IsGenesis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or alternatively do IsGenesis && ctx.BlockHeight() == ctx.InitialHeight() as a defense in depth.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this || here, and just use IsGenesis

Too many tests fail that would require funky re-wiring. This is why I suggested to add the || to keep the tests passing. Probably because IsGenesis returns false as it does not go through the InitGenesis flow.

Alternatively, the || ctx.BlockHeight() == ctx.InitialHeight() can work too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah @ValarDragon we switched it to the OR due to tests failing, should we aim to rewrite the tests or does this implementation work?

Copy link
Collaborator

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@czarcas7ic czarcas7ic merged commit 3e46ff7 into v0.45.0x-osmo-v7 Jun 20, 2022
@czarcas7ic czarcas7ic deleted the adam/is-genesis branch June 20, 2022 20:06
czarcas7ic added a commit that referenced this pull request Jun 20, 2022
* is gen test

* my attempt at isGenesis

* logs and uncomment

* more changes

* comment out

* change init gen call loc

* further gen tests

* more tests

* another test

* revert unneeded changes

* remove extra

* reset to false

* Update x/auth/ante/sigverify.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* changes from call with bez

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
czarcas7ic added a commit that referenced this pull request Jun 20, 2022
* is gen test

* my attempt at isGenesis

* logs and uncomment

* more changes

* comment out

* change init gen call loc

* further gen tests

* more tests

* another test

* revert unneeded changes

* remove extra

* reset to false

* Update x/auth/ante/sigverify.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* changes from call with bez

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
alexanderbez pushed a commit that referenced this pull request Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants